<!-- 选择器 -->
<template>
  <div id="selector">
    <div class="selector-container">
      <div class="selection-rendered">
        <div class="selected-value">{{ defaultSelection }}</div>
      </div>
      <span class="select-arrow">op</span>
    </div>
    <div class="selection-container">
      <div
        class="selection-rendered"
        v-for="(sel, index) in selection"
        :key="index"
        @click="changeSelection(index)"
      >
        <div class="selected-value">selection</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },

  props: ["defaultSelection", "selection"],
  model: {
    prop: "defaultSelection",
    event: "changeSelection",
  },

  components: {},

  computed: {},

  mounted: {},

  methods: {
    changeSelection(value) {
      this.$emit("changeSelection", value);
    },
  },
  watch: {
    defaultSelection(newval, oldval) {
      console.log(newval, oldval);
    },
  },
};
</script>
<style>
#selector {
  position: relative;
  width: 100%;
}
.selector-container {
  position: relative;
  width: 100%;
  height: 30px;
  border-radius: 4px;
  border: 0.5px rgba(175, 175, 175, 0.83) solid;
  font-size: 14px;
  color: rgb(88, 88, 88);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-start;
}
.selection-rendered {
  position: relative;
  display: block;
  height: 30px;
  line-height: 30px;
  margin-left: 11px;
  padding: 1px 0;
}
.selected-value {
  float: left;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.select-arrow {
  position: absolute;
  right: 11px;
  height: 30px;
  font-size: 14px;
  line-height: 30px;
}
.selection-container {
  margin-top: 4px;
  position: relative;
  width: 100%;
  max-height: 400px;
  border-radius: 4px;
  font-size: 14px;
  color: rgb(88, 88, 88);
  box-shadow: 0px 2px 7px #d1d1d1;
  background-color: white;
  overflow-y: scroll;
}
</style>